import request from '@/config/axios'

// 报工记录 VO
export interface WorkReportVO {
  id: number // 编号
  serialNo: string // 序列号
  docNo: string // 工单号
  lineId: number // 产线
  equipment: string // 设备
  process: string // 工序
  qty: number // 数量
  updater: string //报工者
}

// 报工记录 API
export const WorkReportApi = {
  // 查询报工记录分页
  getWorkReportPage: async (params: any) => {
    return await request.get({ url: `/opticore/work-report/page`, params })
  },

  // 查询报工记录详情
  getWorkReport: async (id: number) => {
    return await request.get({ url: `/opticore/work-report/get?id=` + id })
  },

  // 新增报工记录
  createWorkReport: async (data: WorkReportVO) => {
    return await request.post({ url: `/opticore/work-report/create`, data })
  },

  // 修改报工记录
  updateWorkReport: async (data: WorkReportVO) => {
    return await request.put({ url: `/opticore/work-report/update`, data })
  },

  // 删除报工记录
  deleteWorkReport: async (id: number) => {
    return await request.delete({ url: `/opticore/work-report/delete?id=` + id })
  },

  // 导出报工记录 Excel
  exportWorkReport: async (params) => {
    return await request.download({ url: `/opticore/work-report/export-excel`, params })
  },

  // 根据物料序列号获取物料信息
  getWorkInfoBySerialNo: async (serialNo: string,lineName:String) => {
    return await request.get({url: `/opticore/work-report/get-work-serial/${serialNo}/${lineName}`})
  },
  updateWorkReportStatus: async (serialNo: String, productId: String)=> {
    return await request.get({url: `/opticore/work-report/update-work-status/up/${serialNo}/${productId}`})
  }
}
